

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>pysisso.jobs &mdash; pysisso 0.3.2 documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> pysisso
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../tutorial/index.html">Get started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../how-to/index.html">How-to guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../background/index.html">Background information</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../reference/index.html">Technical reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">pysisso</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>pysisso.jobs</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for pysisso.jobs</h1><div class="highlight"><pre>
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>
<span class="c1"># Copyright (c) 2020, Matgenix SRL, All rights reserved.</span>
<span class="c1"># Distributed open source for academic and non-profit users.</span>
<span class="c1"># Contact Matgenix for commercial usage.</span>
<span class="c1"># See LICENSE file for details.</span>

<span class="sd">&quot;&quot;&quot;Module containing the custodian jobs for SISSO.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">subprocess</span>

<span class="kn">from</span> <span class="nn">custodian.custodian</span> <span class="kn">import</span> <span class="n">Job</span>  <span class="c1"># type: ignore</span>
<span class="kn">from</span> <span class="nn">monty.os.path</span> <span class="kn">import</span> <span class="n">which</span>  <span class="c1"># type: ignore</span>


<div class="viewcode-block" id="SISSOJob"><a class="viewcode-back" href="../../api/pysisso.html#pysisso.jobs.SISSOJob">[docs]</a><span class="k">class</span> <span class="nc">SISSOJob</span><span class="p">(</span><span class="n">Job</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Custodian Job to run SISSO.&quot;&quot;&quot;</span>

    <span class="n">INPUT_FILE</span> <span class="o">=</span> <span class="s2">&quot;SISSO.in&quot;</span>
    <span class="n">TRAINING_DATA_DILE</span> <span class="o">=</span> <span class="s2">&quot;train.dat&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
        <span class="bp">self</span><span class="p">,</span>
        <span class="n">SISSO_exe</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;SISSO&quot;</span><span class="p">,</span>
        <span class="n">nprocs</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
        <span class="n">stdout_file</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;SISSO.log&quot;</span><span class="p">,</span>
        <span class="n">stderr_file</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;SISSO.err&quot;</span><span class="p">,</span>
    <span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Construct SISSOJob class.</span>

<span class="sd">        Args:</span>
<span class="sd">            SISSO_exe: Name of the SISSO executable.</span>
<span class="sd">            nprocs: Number of processors for the job.</span>
<span class="sd">            stdout_file: Name of the output file (default: SISSO.log).</span>
<span class="sd">            stderr_file: Name of the error file (default: SISSO.err).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">SISSO_exe</span> <span class="o">=</span> <span class="n">SISSO_exe</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nprocs</span> <span class="o">=</span> <span class="n">nprocs</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">stdout_file</span> <span class="o">=</span> <span class="n">stdout_file</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">stderr_file</span> <span class="o">=</span> <span class="n">stderr_file</span>

<div class="viewcode-block" id="SISSOJob.setup"><a class="viewcode-back" href="../../api/pysisso.html#pysisso.jobs.SISSOJob.setup">[docs]</a>    <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>  <span class="c1"># pragma: no cover</span>
        <span class="sd">&quot;&quot;&quot;Not needed for SISSO.&quot;&quot;&quot;</span>
        <span class="k">pass</span></div>

<div class="viewcode-block" id="SISSOJob.run"><a class="viewcode-back" href="../../api/pysisso.html#pysisso.jobs.SISSOJob.run">[docs]</a>    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;Run SISSO.</span>

<span class="sd">        Returns:</span>
<span class="sd">            a Popen process.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">exe</span> <span class="o">=</span> <span class="n">which</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SISSO_exe</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">exe</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;SISSOJob requires the SISSO executable to be in the path.</span><span class="se">\n</span><span class="s2">&quot;</span>
                <span class="s1">&#39;Default executable name is &quot;SISSO&quot; and you provided &quot;</span><span class="si">{}</span><span class="s1">&quot;.</span><span class="se">\n</span><span class="s1">&#39;</span>
                <span class="s2">&quot;Download the SISSO code at https://github.com/rouyang2017/SISSO &quot;</span>
                <span class="s2">&quot;and compile the executable or fix the name of your executable.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">SISSO_exe</span>
                <span class="p">)</span>
            <span class="p">)</span>

        <span class="k">if</span> <span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nprocs</span> <span class="o">&gt;</span> <span class="mi">1</span>
        <span class="p">):</span>  <span class="c1"># pragma: no cover # Reason: obviously not yet implemented section of code.</span>
            <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;Running SISSO with MPI not yet implemented.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">cmd</span> <span class="o">=</span> <span class="n">exe</span>

        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">stdout_file</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_stdout</span><span class="p">,</span> <span class="nb">open</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">stderr_file</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">,</span> <span class="n">buffering</span><span class="o">=</span><span class="mi">1</span>
        <span class="p">)</span> <span class="k">as</span> <span class="n">f_stderr</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">f_stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">f_stderr</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">p</span></div>

<div class="viewcode-block" id="SISSOJob.postprocess"><a class="viewcode-back" href="../../api/pysisso.html#pysisso.jobs.SISSOJob.postprocess">[docs]</a>    <span class="k">def</span> <span class="nf">postprocess</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Not needed for SISSO.&quot;&quot;&quot;</span></div></div>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2020, Matgenix SRL.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>